﻿<!DOCTYPE html>
<html>
 <head> 
  <meta charset="utf-8" /> 
  <title>添加老师</title> 
  <meta name="renderer" content="webkit" /> 
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> 
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> 
  <!-- // 样式表单--> 
  <script src="../../../layui/src/layui.js"></script> 
  <link href="../../../layui/src/css/layui.css" rel="stylesheet" /> 
  <link href="../../../layui/layui/css/layui.css" rel="stylesheet" /> 
  <!--上传--> 
  <script src="../../../js/js/jquery/jquery-1.10.2.min.js"></script> 
  <link href="../../../layui/layui/uploader.css" rel="stylesheet" /> 
  <script src="../../../layui/uploader/webuploader/webuploader.min.js"></script> 
  <script src="../../../layui/uploader/uploader.js"></script> 
  <style>
body{padding: 10px;}
</style> 
 </head> 
 <body > 
  <form class="layui-form layui-form-pane1" action="" lay-filter="first" id ="teacher-add"> 
   <div class="layui-form-item"> 
    <label class="layui-form-label">姓名</label> 
    <div class="layui-input-block"> 
     <input type="text" name="name" id="name" lay-verify="required|title" required="" placeholder="请输入老师姓名" autocomplete="off" class="layui-input" /> 
    </div> 
   </div> 
   <div class="layui-form-item"> 
    <div class="layui-inline"> 
     <label class="layui-form-label">上传头像</label> 
     <div class="layui-input-inline"> 
      <input type="text" name="avatar" id="avatar" autocomplete="off" class="layui-input upload-path" />
      <div class="upload-box upload-img"></div> 
     </div> 
    </div> 
   </div> 
   <div class="layui-form-item" pane=""> 
    <label class="layui-form-label">性别</label> 
    <div class="layui-input-block"> 
     <input type="radio" name="gender" id="genderboy" value="男" title="男" /> 
     <input type="radio" name="gender" id="gendergirl" value="女" title="女" checked="" /> 
    </div> 
   </div> 
     <div class="layui-form-item"> 
    <label class="layui-form-label">手机</label> 
    <div class="layui-input-block"> 
     <input type="tel" name="phone" id="phone" lay-verify="required|number" lay-vertype="tips" autocomplete="off" class="layui-input" /> 
    </div> 
   </div> 

   <div class="layui-form-item"> 
    <label class="layui-form-label">毕业学校</label> 
    <div class="layui-input-block"> 
     <input type="text" name="school" id="school" lay-verify="required|title" required="" placeholder="请输入学校|单位" autocomplete="off" class="layui-input" /> 
    </div> 
   </div> 
     <div class="layui-form-item"> 
    <div class="layui-inline"> 
     <label class="layui-form-label">凭证</label> 
     <div class="layui-input-inline"> 
      <input type="text" name="diploma" id="diploma" autocomplete="off" class="layui-input upload-path" />
      <div class="upload-box upload-img"></div> 
     </div> 
    </div> 
   </div> 

   <div class="layui-form-item layui-form-text"> 
    <label class="layui-form-label">请填写描述</label> 
    <div class="layui-input-block"> 
     <textarea placeholder="请输入内容" class="layui-textarea" name="remark" id="remark"></textarea> 
    </div> 
   </div> 
   <div class="layui-form-item"> 
    <div class="layui-input-block"> 
     <button class="layui-btn" lay-submit="" lay-filter="*" onclick="addTeacher()">立即提交</button> 
 
    </div> 
   </div> 
  </form> 
  <script>

      $(function () {
          //初始化上传控件
          $(".upload-img").InitUploader({ filesize: "0", sendurl: "../../../ChireInter/Other/Upload/fileupload.ashx", swf: "../layui/uploader/webuploader/uploader.swf", filetypes: "jpg,jpeg,png,gif,bmp" });
      });

      // 进行提交
      function addTeacher() {
          addStudentsInterface();
      }

      function addStudentsInterface() {

          var gender = "";
          if ($('#genderboy').is(':checked')) {
              gender = "男";
          } else {
              gender = "女";
          }

          var args = $.param({
              "gender": gender
          }) + "&" + $('#teacher-add').serialize();

          $.ajax({
              url: '../../../ChireInter/Teacher/Teacher_Add.ashx',
              data: $('#teacher-add').serialize(),
              type: 'post',
              dataType: 'json',
              success: function (res) {
                  if (res.errCode == 200) {
                      alert("添加成功");
                  } else {
                      alert("添加失败");
                  }
              },
              error: function (err) {

              }
          })
      }

      // 刷新表单

          layui.use(['form'], function () {
              var form = layui.form
              , layer = layui.layer;
          });

  </script>   
 </body>
</html>